package vivek.project.pocketmoney.expenses
{
	import flash.data.*;
	import flash.errors.*;
	import mx.controls.Alert;
	import vivek.project.pocketmoney.common.CommonData;
	import vivek.project.pocketmoney.expenses.model.PMSqlStatement;
	import vivek.project.pocketmoney.expenses.scripts.ExpenseSQLScript;

	public class SummaryScript
	{
		[Bindable]
		public static var accountSummary:Array=new Array();

		public function SummaryScript()
		{
			getAccountSummary();
		}
		private var ACCOUNT_SUMMARY_STRING:String=ExpenseSQLScript.EXPENSE_SUMMARY_QUERY;

		public function getAccountSummary():void
		{
			try
			{
				var _statement:SQLStatement=new PMSqlStatement();
				var _sqlConnection:SQLConnection=CommonData.getConnection();
				//_sqlConnection.open(); 
				_statement.sqlConnection=_sqlConnection;
				_statement.text=ACCOUNT_SUMMARY_STRING;
				_statement.execute();
				accountSummary=_statement.getResult().data
				_sqlConnection.close();
			}
			catch (sqlError:SQLError)
			{
				Alert.show(sqlError.details);
			}
		}
	}
}